<!--我的消息-->
<template>
    <view class="setting">
        <scroll-view scroll-y="true" class="swiper-item-box">
            <view class="list_block">
                <navigator class="item_bock" url="/pages/personalCenter/accountSecurity">
                    <view class="title">
                        <image class="title_img" src="https://gatherabc.oss-cn-qingdao.aliyuncs.com/xcx/password.png"></image>
                        <text class="title-text">账号与安全</text>
                    </view>
                    <view class="title">
                        <image class="item_img" src="https://gatherabc.oss-cn-qingdao.aliyuncs.com/xcx/goto.png"></image>
                    </view>
                </navigator>
                <navigator class="item_bock" url="/pages/common/address">
                    <view class="title">
                        <image class="title_img" src="https://gatherabc.oss-cn-qingdao.aliyuncs.com/xcx/address.png"></image>
                        <text class="title-text">地址与管理</text>
                    </view>
                    <view class="title">
                        <image class="item_img" src="https://gatherabc.oss-cn-qingdao.aliyuncs.com/xcx/goto.png"></image>
                    </view>
                </navigator>
                <navigator class="item_bock" url="/pages/personalCenter/accountBind">
                    <view class="title">
                        <image class="title_img" src="https://gatherabc.oss-cn-qingdao.aliyuncs.com/xcx/account.png"></image>
                        <text class="title-text">收款账户</text>
                    </view>
                    <view class="title">
                        <image class="item_img" src="https://gatherabc.oss-cn-qingdao.aliyuncs.com/xcx/goto.png"></image>
                    </view>
                </navigator>
                <navigator class="item_bock" url="/pages/aboutus/aboutMe">
                    <view class="title">
                        <image class="title_img" src="https://gatherabc.oss-cn-qingdao.aliyuncs.com/xcx/icon-about.png"></image>
                        <text class="title-text">关于我们</text>
                    </view>
                    <view class="title">
                        <image class="item_img" src="https://gatherabc.oss-cn-qingdao.aliyuncs.com/xcx/goto.png"></image>
                    </view>
                </navigator>
            </view>
        </scroll-view>
    </view>
    <view class="add_wrap">
        <view class="button type_main" @tap="loginOut">退出登录</view>
    </view>
</template>
<script>
    import wepy from 'wepy'
    import api from '@/api/api'
    import tip from '@/utils/tip'
    import {SYSTEM_INFO, USER_SPECICAL_INFO, USER_ID} from '@/utils/constant'

    export default class setting extends wepy.page {
      config = {
        navigationBarTitleText: '设置',
        tabBar: {
          color: '#999999',
          selectedColor: '#ff6a3c',
          backgroundColor: '#ffffff',
          borderStyle: 'black',
          list: [
            {
              pagePath: 'pages/personalCenter/me',
              text: '退出登录',
              iconPath: 'images/icon_info.png',
              selectedIconPath: 'images/icon_info_active.png'
            }
          ]
        }
      }
      components = {}
      data = {
        userInfo: {},
        winHeight: 0
      }

      // 退出登录
      async loginOut() {
        let self = this
        let token = wepy.getStorageSync('token')
        if (!token) {
          return tip.toast('已经是登出状态', null, 'none')
        }
        api
          .logout(
            {
              query: {}
            },
            'token=' + token
          )
          .then(function(res) {
            if (res.data.code == '0') {
              wepy.removeStorageSync('userId')
              wepy.removeStorageSync('refreshToken')
              wepy.removeStorageSync('token')
              wepy.navigateTo({
                url: '/pages/personalCenter/login'
              })
            }
          })
      }

      // async getUserInfo(phone,code) {
      //   let that = this;
      //   let userSpecialInfo = wepy.getStorageSync(USER_SPECICAL_INFO) || {};
      //   let openId = userSpecialInfo.openid;
      //   const json = await api.getUserInfo({
      //     query: {
      //       openId: openId
      //     }
      //   });
      //   if (json.data.code == 0) {
      //     this.userInfo=json.data.user;
      //     console.log("===================")
      //     console.log(that.userInfo);
      //     that.$apply();
      //   } else {
      //     tip.error(json.data.msg)
      //   }
      //   that.showLoading = false;
      //    onLoad(){
      //        //设置滚动高度
      ////        let systemInfo = wepy.getStorageSync(SYSTEM_INFO);
      ////        this.winHeight = systemInfo.windowHeight;
      //        // this.getUserInfo();
      //    };
      computed = {}
      methods = {
        loginOut() {
          this.loginOut()
        }
      }
      events = {}
    }
</script>
<style lang="less">
.setting {
    .list_block {
        padding-top: 20rpx;
    }

    .item_bock {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 20rpx 25rpx;
        border-bottom: 1px solid #f7f7f7;
        background: #fff;
        margin-top: 20rpx;
    }
    .title-text {
        margin-left: 20rpx;
        vertical-align: middle;
    }
    .title_img {
        width: 30rpx;
        height: 30rpx;
        vertical-align: middle;
    }
    .item_img {
        width: 30rpx;
        height: 30rpx;
    }
    .title {
        font-size: 32rpx;
    }

    .item_content {
        font-size: 32rpx;
        color: #333333;
    }
}

.add_wrap {
    display: block;
    width: 95%;
    left: 0;
    right: 0;
    position: absolute;
    bottom: 20rpx;
    margin: 0 auto;
}
</style>
